<template>
  <div class="collect-page">
<van-nav-bar title="我的喜欢" left-text="返回" left-arrow @click="$router.push('/article')" @click-left="onClickLeft">
  <template #right>
    <img @click="$router.push('/sou')" src="../assets/image.png" alt="">
  </template>
</van-nav-bar>
<!-- <van-nav-bar>
  <template #title>
    我的收藏
  </template>
</van-nav-bar> -->
<van-list @load="getList" v-model="loading"  :finished="finished">
  <ArticleItem v-for="item in list" :key="item.id" :item="item"></ArticleItem>
</van-list>

  </div>
</template>

<script>

// import { getArticleApi } from '@/api/article'
import { getCollectApi } from '@/api/article'
export default {
  name: 'CollectPage',

  data () {
    return {
      list: [],
      page: 2,
      pageSize: 10,
      loading: false,
      finished: false,
      optType: 1,
      pageTotal: 0

    }
  },
  created () {
    // this.getList()
  },
  methods: {
    onClickLeft () {
      this.$router.push('/article')
    },
    // async getList () {
    //   const res = await getArticleApi(this.current, this.pageSize, this.sort)
    //   console.log(res)
    //   this.list.push(...res.data.rows)
    //   this.loading = false
    //   if (this.current > res.data.pageTotal) {
    //     this.finished = true
    //   }
    //   this.current++
    //   this.pageTotal = res.data.pageTotal
    // }

    async getList () {
      const res = await getCollectApi(this.page, this.pageSize, this.optType)
      // this.page = res.data.page
      // this.pageSize = res.data.pageSize
      // console.log(res)
      this.list.push(...res.data.rows)
      this.page++
      this.loading = false
      if (this.page > res.data.pageTotal) {
        this.finished = true
      }
    }
  }
}
</script>

<style lang="less" scoped>
.collect-page {
  margin-bottom: 50px;
  margin-top: 44px;
  .my-nav {
    height: 44px;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    z-index: 999;
    background: #fff;
    display: flex;
    align-items: center;
    > a {
      color: #999;
      font-size: 14px;
      line-height: 44px;
      margin-left: 20px;
      position: relative;
      transition: all 0.3s;
      &::after {
        content: '';
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        bottom: 0;
        width: 0;
        height: 2px;
        background: #222;
        transition: all 0.3s;
      }
      &.active {
        color: #222;
        &::after {
          width: 14px;
        }
      }
    }
    .logo {
      flex: 1;
      display: flex;
      justify-content: flex-end;
      > img {
        width: 64px;
        height: 28px;
        display: block;
        margin-right: 10px;
      }
    }
  }
}

</style>
